#ifndef FileTransferPanel_H_
#define FileTransferPanel_H_

#include <map>

#include <wx/hyperlink.h>

#include "tux.h"

class MsnSession;
class FileTransferConnection;

enum FileTransferStatus
{
	FT_WAITING = 0,
	FT_ACCEPTING,
	FT_TRANSFERRING,
	FT_DONE,
	FT_CANCELLED,
	FT_FAILED
};

class FileTransferEntry;
class FileTransferPanel;

class FileTransferBar : wxPanel
{
friend class FileTransferPanel;

protected:
	FileTransferStatus ftStatus;

	//FileTransferEntry* ftItem;

	MsnSession* session;


	bool isSender;
	wxString sessionID;
	wxString fileName;
	
	int fileSize;

	wxString filePath;


protected:

	FileTransferPanel* ftPanel;

	wxStaticText* nameLabel;

	wxStaticText* statusLabel;

	wxStaticText* progressLabel;
	wxStaticText* progressText;

	wxGauge* progressGauge;

	wxHyperlinkCtrl* acceptLink;
	wxHyperlinkCtrl* saveasLink;
	wxHyperlinkCtrl* declineLink;

	wxHyperlinkCtrl* cancelLink ;
	wxHyperlinkCtrl* openLink;
	wxHyperlinkCtrl* removeLink;

public:

	FileTransferBar(FileTransferPanel* panel, FileTransferEntry* ftItem);
	virtual ~FileTransferBar();

	void UpdateUIStatus(FileTransferStatus status);
	
	void CancelFile();

	void CleanFile();

private:
	void OnAccept(wxHyperlinkEvent& event);
	void OnSaveas(wxHyperlinkEvent& event);
	void OnDecline(wxHyperlinkEvent& event);

	void OnCancel(wxHyperlinkEvent& event);
	void OnRemove(wxHyperlinkEvent& event);
	void OnOpen(wxHyperlinkEvent& event);

DECLARE_EVENT_TABLE()

};


class FileTransferPanel : public wxPanel
{
friend class FileTransferBar;
typedef std::map<wxString, FileTransferBar*> EntryMap;

private:
	wxBoxSizer *fileSizer;
	wxScrolledWindow* scrolledWindow;
	EntryMap entryMap;

public:
	FileTransferPanel(wxWindow* parent);
	virtual ~FileTransferPanel();

	void UpdateUIText();

	void AddFileTransfer(FileTransferEntry* item);

	bool HasLiveItem(MsnSession* session);
	bool HasLiveItemOthers(MsnSession* session);
	bool HasLiveItemAll();

	void CancelLiveItem(MsnSession* session);
	void CancelLiveItemOthers(MsnSession* session);
	void CancelLiveItemAll();

	void OnTransferStarted(const wxString& cookie);
	void OnTransferUpdated(const wxString& cookie, long long value, long speed);
	void OnTransferDone(const wxString& cookie);
	void OnTransferFailed(const wxString& cookie);
	void OnTransferCancelled(const wxString& cookie);

	void OnClose(wxCloseEvent &event);

DECLARE_EVENT_TABLE()

};

#endif // wxMAIN_H
